package com.offcn.service;

import com.offcn.beans.User;
import com.offcn.dao.UserDao;
import com.offcn.utils.PageTool;

import javax.servlet.http.HttpSession;
import java.util.List;

public class UserService {
    // 使用UserDao对象
    private UserDao userDao = new UserDao();
    public boolean adminLogin(String username, String password, HttpSession session) {
        User user = userDao.adminLogin(username, password);
        if (user != null) {
            session.setAttribute("user", user);
            return true;
        }
        return false;
    }

    public List<User> findAllUser(PageTool pageTool, String search) {
       return userDao.findAllUser(pageTool,search);
    }

    public int findTotalCount(String search) {
        return userDao.findTotalCount(search);
    }

    public boolean addUser(User user) {
        int row = userDao.addUser(user);
        return row > 0;
    }
}